Vue.component('xcform_control_selectmulti', {
    template: '<el-form-item \
                  :class="value.fieldjsonObj.xcform_prop_required.value?\'required\':\'\'"\
                  :prop="value.fieldcode" \
                  :rules="control.rules" \
                  :label="value.fieldtitle"> \
                  <el-checkbox-group v-if="value.fieldjsonObj.xcform_base_property_input_selectmulti.type==\'checkbox\'" \
                    v-model="value.value" :disabled="control.disabled"> \
                    <el-checkbox v-for="option in value.fieldjsonObj.xcform_base_inputoptions.options" :key="option.value" :label="option.value"></el-checkbox> \
                  </el-checkbox-group> \
                  <el-select v-if="value.fieldjsonObj.xcform_base_property_input_selectmulti.type==\'select\'" \
                    v-model="value.value" :placeholder="value.fieldjsonObj.xcform_base_placeholder.value" multiple> \
                    <el-option v-for="option in value.fieldjsonObj.xcform_base_inputoptions.options" :key="option.value" :label="option.value" :value="option.value"></el-option> \
                  </el-select> \
                </el-form-item>',
    props: {
        value: {
            type: Object,
        },
        disabled: {
            type: Boolean,
        },
        fieldfulljson: {
            type: Array,
        },
        xcform_id: {
            type: Number,
        }
    },
    data() {
        var validateFunction = (rule, value, callback) => {
            var that = this;
            that.value.value = (that.value.value) ? that.value.value : "";

            if (that.value.fieldjsonObj.xcform_prop_required.value) {
                if (that.value.value.length == 0) {
                    return callback(new Error('不能为空'));
                }
            }
            return callback();
        };
        return {
            control: {
                disabled: false,
                rules: [{
                    validator: validateFunction,
                    trigger: 'blur'
                }]
            }
        };
    },
    created() {
        var that = this;
        that.control.disabled = that.disabled;
        if (that.value.fieldjsonObj.xcform_prop_readonly.value) {
            that.control.disabled = true;
        }

        that.value.value = (that.value.value) ? that.value.value : [];
    },
    mounted() {
        var that = this;

    },
    methods: {}
});